﻿#include <iostream>
#include <vector>
using namespace std;

class Solution
{
    const int INF = 0x3f3f3f3f;
public:
    // 279. 完全平方数
    int numSquares(int n)
    {
        int k = sqrt(n) + 1;
        vector<int> dp(n + 1);

        for (int j = 1; j <= n; j++)
            dp[j] = INF;

        for (int i = 1; i <= k; i++)
            for (int j = i * i; j <= n; j++)
                dp[j] = min(dp[j], dp[j - i * i] + 1);
        return dp[n];
    }

    /*int numSquares(int n)
    {
        int k = sqrt(n) + 1;
        vector<vector<int>> dp(k + 1, vector<int>(n + 1));

        for (int j = 1; j <= n; j++)
            dp[0][j] = INF;

        for (int i = 1; i <= k; i++)
            for (int j = 1; j <= n; j++)
            {
                dp[i][j] = dp[i - 1][j];
                if (j >= i * i)
                    dp[i][j] = min(dp[i][j], dp[i][j - i * i] + 1);
            }
        return dp[k][n];*/
};

int main()
{

    return 0;
}